#!/bin/bash

. ~/venv_duck/bin/activate
cd ~/Open_Duck_Mini_Runtime/scripts/

echo 'Trying to kill any running instances of v2_rl_walk_mujoco.py...'
if pkill -f 'python v2_rl_walk_mujoco.py'; then
    echo "Process(es) found and signaled. Sleeping for 1 second."
    sleep 1
else
    exit_code=$?
    if [ $exit_code -eq 1 ]; then
        echo "No matching processes found to kill. Skipping."
    else
        echo "pkill failed with an unexpected error (Exit code: $exit_code)."
    fi
fi

echo 'Running v2_rl_walk_mujoco.py...'
python v2_rl_walk_mujoco.py --onnx_model_path $(dirname "$0")/temp.onnx
